#!/usr/bin/env ruby
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
require 'rubygems'
require 'git_reflow'

reflow_command = ARGV.shift
if reflow_command.nil? || GitReflow.workflow.commands[reflow_command.to_sym].nil?
  GitReflow.help
elsif ARGV.include? "--help"
  GitReflow.documentation_for_command(reflow_command)
else
  trap 'INT' do
    GitReflow.say "Aborted.", :error
    exit
  end

  command_options = GitReflow.parse_command_options!(reflow_command)
  GitReflow.logger.debug "Running command `#{reflow_command}` with options: #{command_options.inspect}"
  GitReflow.public_send(reflow_command.to_sym, command_options)
end
